package com.antdesignbackend.backend.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.SchedulingConfigurer;
import org.springframework.scheduling.config.ScheduledTaskRegistrar;

import java.util.concurrent.ScheduledThreadPoolExecutor;

/**
 * Scheduled并行任务
 */
@Configuration
public class ScheduledConfig implements SchedulingConfigurer {
    /**
     * 修改默认线程池大小，默认为1
     *
     * @return
     */
    @Override
    public void configureTasks(ScheduledTaskRegistrar scheduledTaskRegistrar) {
        scheduledTaskRegistrar.setScheduler(new ScheduledThreadPoolExecutor(10,
                r -> new Thread(r, "my-schedule-pool")));
    }
}
